package com.woniu.web.controller.bedinfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.resultSet.Result;
import com.woniu.resultSet.Status;
import com.woniu.web.service.TbJpMalfunctionService;
import io.swagger.models.auth.In;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author jiaoxiuxiu
 * @date 2020/9/28 12:06
 */
@RestController
@RequestMapping("/fault")
public class FaultrecordController {
    @Resource
    TbJpMalfunctionService tbJpMalfunctionService;

    //按条件及分页进行查询
    @PostMapping("/findAll/{id}")
    public Result findAllByExample(@PathVariable Integer id, @RequestBody Page page){
        //设置起始页
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        //按条件查询数据
        List list =tbJpMalfunctionService.findByBedId(id);
        //将查询到的数据进行分页
        PageInfo pageInfo = new PageInfo(list);
        //将查询到的数据返回页面
        if (list.size()!=0){
            return new Result(Status.SUCCESS,"查询成功",pageInfo);
        }else{
            return new Result(Status.FAIL,"查询失败",pageInfo);
        }
    }
}
